package com.example.iotest.bio;

import java.io.File;
import java.io.FileInputStream;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.function.Consumer;

public class Test1 {
    public static void main(String[] args) throws Exception {
        File file = new File("D:\\Resources\\GitProjects\\io-test\\io-test\\io-test\\src\\main\\resources\\files\\1.txt");
        try (FileInputStream in = new FileInputStream(file)
        ) {
            final byte[] buffer = new byte[3];
            int length;
            while ((length=in.read(buffer))!=-1){
                System.out.println(new String(buffer,0,length));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        try (FileInputStream in = new FileInputStream(file)
        ) {
            int b;
            while (((b=in.read()))!=-1){
                System.out.print((char)b);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

//        FileReader
        String s="镕";
        int length = s.getBytes(StandardCharsets.UTF_8).length;
        System.out.println(length);
        System.out.println(s.getBytes("gbk").length);
        String encode = URLEncoder.encode("吴", "utf-8");
        String decode = URLDecoder.decode("%41%11%11", "utf-8");
        System.out.println(encode);
        System.out.println(decode);

        Thread t=new Thread(System.out::println);
        ArrayList<String> list=new ArrayList<>();
        list.add("2");
        String set = list.set(0, "1");
        System.out.println("set "+set);
        Consumer<String> runnable = System.out::println;
        runnable.accept("11");
        Runnable runnable1 = System.out::println;
        Callable<Object> callable = Executors.callable(() -> System.out.println(11));
        Object call = callable.call();
        System.out.println(call);
        A<String,String,String> a=new Test1()::f;
        a.f("a1","2","3");

    }
    void f(String s1,String s2,String s3){
        System.out.println(s1+s2+s3);
    }
}

interface A<X,Y,Z>{
    void f(X x,Y y,Z z);
}
